{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 计算样本之间的距离"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1、欧拉距离<br>\n",
    "2、曼哈顿距离<br>\n",
    "3、明可夫斯基距离<br>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAH/JJREFUeJzt3Xuc1mP+x/HXZ2pIJLbGitKwrK3p3K0DW1IkRUJroyJi9CtyPpMNWWHlnO2AJMcSqRxClFN1l87Z1fbIaa1yqBAR1++P645MM809zX3f1314Px+P+zH34TLfz+Orec93vt/r+7nMOYeIiGSXvNAFiIhI4incRUSykMJdRCQLKdxFRLKQwl1EJAsp3EVEspDCXUQkCyncRUSykMJdRCQLVQ214dq1a7vCwsJQmxcRyUjz58//3DlXUN64YOFeWFhINBoNtXkRkYxkZh/EM06nZUREspDCXUQkCyncRUSykMJdRCQLKdxFRLJQ3OFuZlXM7F0zm1rKZzub2RNmttLM5phZYSKL/MWECVBYCHl5/uuECUnZjIhIpqvIkfv5wIoyPusPfOWcOxAYAQyvbGHbmDABiovhgw/AOf+1uFgBLyJSirjC3czqAt2AMWUMOR4YF3s+EehkZlb58rZy9dWwceNv39u40b8vIiK/Ee+R+x3AZcDPZXy+L/ARgHNuM7AeqFVykJkVm1nUzKJr166tWKUfflix90VEcli54W5mxwJrnHPzK7sx59wo51zEORcpKCj37tnf2m+/0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EyljCPnV1Oee+cM5tir0cA7RMQTmHAd3NbDXwONDRzB4pMSbE/iq3rkD7a8u2P4l9XQNMBlqVGJK0n8lMD/e0XJzbzPbecq7RzFrh93NS/5HHtjcWWOGcu72MYSnfX/HUFWh/FZjZHrHnuwBHAe+VGDYFOD32vCfwqotdBQtZV4lzst3x1zGSyjl3pXOurnOuEH+x9FXnXJ8Sw1K+v+KpK8T+im13VzOrseU50BkoOcMuaT+T5S6QHZKl6eLccdTVE/g/M9sMfAf0SvY/cvwRTF9gSex8LcBVwH5b1RVif8VTV4j9VQcYZ2ZV8L9MnnTOTTWz64Goc24K/pfSeDNbib+A3ivJNcVb12Az6w5sjtXVLwV1lSoN9lc8dYXaX78HJseOW6oCjzrnXjCzAZD8n0ndoSoikoUy/bSMiIiUQuEuIpKFFO4iIllI4S4ikoUU7iIiWUjhLiKShRTuIiJZSOEuIpKF/h8b5+Ta3UwwUwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "X = np.array([[5, 1],    # a\n",
    "                 [1, 4]])    # b\n",
    "plt.plot(X[0], X[1], 'r-o')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xuc1nP+//HHqxpqHGKbbKjEWm1NaaqRDiQKSRIl2YohilgipxKWymlDTkVko0KJqORUJJQ0MZ1FP99sWVaFQrJl378/3hcyzTTX1HXN+/pc87zfbnNzHd5zfZ772ZnXfPp83p/X25xziIhIeqk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/hxvjj/q2F3R/7SQXBNhfsX/KFwBfAa8754rdX865bcBGoFoK5ALoEvtn/GQzq5XsTDEjgGuB/xXzfpD9FUcuCLO/wP9hfs3MFppfQ7qwpP1ORr24p6oP8LcINwIeAF4oqw2b2d7Ac0B/59ymstpuSUrIFWR/Oed+ds7lADWBZma2wxrBIcSRaxpQxzl3JPA6vx0tJ42ZdQS+cs4tTPa2SiPOXGW+v7ZzjHOuCXAKcKmZtS6rDUe9uH8ObP9XuGbstaCcc5t++ae1c24GkGFmWcnerpll4AvoBOfc80UMCbK/SsoVan9tt/1vgTeB9oXe+nV/mVkloCqwIXQu59wG59xPsaePAU3LIE4roJOZrQaeAU4ws/GFxoTYXyXmCrS/ftn257H/fgVMAZoVGpK038moF/eUXJzbzGr8cq7RzJrh93NSf8hj2xsDrHDO3VPMsDLfX/HkCrS/qpvZfrHHVYATgY8KDZsKnBd73BV4w8WugoXMVeicbCf8dYykcs4NdM7VdM7VwV8sfcM517PQsDLfX/HkCrG/Ytvdy8z2+eUxcBJQeIZd0n4nS1wgOyRL0cW548jVFbjEzLYBPwLdk/1Djj+C6QUsiZ2vBRgE1N4uV4j9FU+uEPvrQOAJM6uI/2MyyTk33cxuBfKdc1Pxf5TGmdkq/AX07knOFG+uy82sE7AtliuvDHIVKQX2Vzy5Qu2vPwJTYsctlYCnnHOvmNnFkPzfSd2hKiKShqJ+WkZERIqg4i4ikoZU3EVE0pCKu4hIGlJxFxFJQyruIiJpSMVdRCQNqbiLiKSh/w+RVqjk8v1WNQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(X[0], X[1], 'r-o')\n",
    "\n",
    "plt.annotate('a', xy=X[0])\n",
    "plt.annotate('b', xy=X[1])\n",
    "\n",
    "plt.plot([5, 1], [1, 1], 'g--')\n",
    "plt.plot([1, 1], [1, 4], 'g--')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 欧拉距离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "((5-1)**2 + (1-4)**2)**(1/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[5, 1],\n",
       "       [1, 4]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用 numpy 求欧拉距离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sum((X[0] - X[1])**2)**(1/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 曼哈顿距离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def distance(a, b, p=2):\n",
    "    return np.sum(np.abs(a - b) ** p) ** (1/p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7.0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(X[0], X[1], 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(X[0], X[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 明可夫斯基距离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.497941445275415"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(X[0], X[1], 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "Y = np.array([[5, 1, 11, 6],     # a\n",
    "             [1, 4, 43, 99]])      # b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "98.47842403288143"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(Y[0], Y[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "132.0"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(Y[0], Y[1], 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "94.24952566326392"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "distance(Y[0], Y[1], 3)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
